package io.polly.ldz.reactor.security;

import io.polly.ldz.reactor.context.SystemCode;
import io.polly.ldz.reactor.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * @version 3.5.0
 * @description: 账号验证异常
 * Copyright (C), 2020-2021,
 * @date 2021/12/25 9:45
 */
@Component
public class RestAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {

    @Autowired
    private UserService userService;

    @Autowired
    private ApplicationEventPublisher eventPublisher;
    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) {

            RestUtil.response(response, SystemCode.AuthError.getCode(), exception.getMessage());

    }
}
